package com.sk.seckilldemo.controller;

import com.sk.seckilldemo.entity.ProductInfo;
import com.sk.seckilldemo.service.ProductService;
import com.sk.seckilldemo.util.Pager;
import com.sk.seckilldemo.util.Response;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

/**
 * 商品管理控制器接口API
 * e4glet
 * 2025年7月2日
 * */
@RestController
@CrossOrigin
@RequestMapping("/product")
@RequiredArgsConstructor
public class ProductController {
    private final ProductService productService;


    /**
     * 添加商品
     * */
    @PostMapping("/add")
    public Response addProduct(@RequestBody ProductInfo product){
        return productService.addProduct(product);
    }

    /**
     * 编辑商品
     * */
    @PostMapping("/edit")
    public Response editProduct(@RequestBody ProductInfo productInfo){
        return productService.editProduct(productInfo);
    }


    /**
     * 删除商品
     * */
    @PostMapping("/delete")
    public Response deleteProduct(@RequestBody ProductInfo productInfo){
        return productService.deleteProduct(productInfo);
    }

    /**
     * 查询商品分页数据
     * */
    @PostMapping("/pagerlist")
    public Response getProductPagerData(@RequestBody Pager pager){
        return productService.getProductPagerData(pager);
    }
}
